package org.xiaodongwei.jvm.exe;

import java.util.ArrayDeque;
import java.util.Deque;

/**
 * JVM 虚拟机栈，用于对函数执行过程中栈帧的管理
 * 栈的特性：先进后出
 *
 * 分析一下函数调用过程中JVM栈中的变化情况
 */
public class JVMStack {
    private final Deque<JVMStackFrame> stack = new ArrayDeque<>();

    public boolean isEmpty() {
        return stack.isEmpty();
    }

    public JVMStackFrame peek() {
        return stack.peek();
    }

    public JVMStackFrame pop() {
        return stack.pop();
    }

    public void push(JVMStackFrame frame) {
        stack.push(frame);
    }
}
